home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Apple Reference & Presen…rary 8 (Internal Edition)
/
Apple R&P Lib Internal v8.0.iso
/
3-Presentations
/
Markets
/
K-12 Education
/
HyperCard in Education
/
Towers of Hanoi
/
stack.txt
< prev
Wrap
Text File
|
1990-02-20
|
5KB
|
132 lines
-- stack: in
-- format: 8 (HyperCard 1)
-- flags: 0x1000 (none)
-- protect password hash: 0
-- maximum user level: 5 (scripting)
-- window: Rect(x1=0, y1=0, x2=0, y2=0)
-- screen: Rect(x1=0, y1=0, x2=0, y2=0)
-- card dimensions: w=0 h=0
-- scroll: x=0 y=0
-- background count: 1
-- first background id: 2783
-- card count: 1
-- first card id: 3043
-- list block id: 3313
-- print block id: 0
-- font table block id: 0
-- style table block id: 0
-- free block count: 0
-- free size: 0 bytes
-- total size: 15360 bytes
-- stack block size: 4096 bytes
-- created by hypercard version: 0x00000000
-- compacted by hypercard version: 0x01228000
-- modified by hypercard version: 0x01228000
-- opened by hypercard version: 0x01228000
-- patterns[0]: 0x0000000000000000
-- patterns[1]: 0x8000000008000000
-- patterns[2]: 0x8800220088002200
-- patterns[3]: 0x8888222288882222
-- patterns[4]: 0x88AA22AA88AA22AA
-- patterns[5]: 0xCCAA33AACCAA33AA
-- patterns[6]: 0xEEAABBAAEEAABBAA
-- patterns[7]: 0xEEBBBBEEEEBBBBEE
-- patterns[8]: 0xFFBBFFEEFFBBFFEE
-- patterns[9]: 0xFFBBFFFFFFBBFFFF
-- patterns[10]: 0x8010022001084004
-- patterns[11]: 0xFFFFFFFFFFFFFFFF
-- patterns[12]: 0x8822882288228822
-- patterns[13]: 0x1122448811224488
-- patterns[14]: 0xC4800C6843023026
-- patterns[15]: 0xB130031BD8C00C8D
-- patterns[16]: 0xAA00AA00AA00AA00
-- patterns[17]: 0x8822552288225522
-- patterns[18]: 0x8855225588552255
-- patterns[19]: 0x77DD77DD77DD77DD
-- patterns[20]: 0x8000000000000000
-- patterns[21]: 0xAA55AA55AA55AA55
-- patterns[22]: 0x038448300C020101
-- patterns[23]: 0x8244394482010101
-- patterns[24]: 0x8814224188412214
-- patterns[25]: 0x8080413E080814E3
-- patterns[26]: 0x22048C7422179810
-- patterns[27]: 0xBE808808EB088880
-- patterns[28]: 0x25C8328964244C92
-- patterns[29]: 0xA29C41BE2AC914EB
-- patterns[30]: 0x40A00000040A0000
-- patterns[31]: 0x8040200002040800
-- patterns[32]: 0xAA00800088008000
-- patterns[33]: 0xFF80808080808080
-- patterns[34]: 0x081C22C180010204
-- patterns[35]: 0xFF808080FF080808
-- patterns[36]: 0xF87422478F172271
-- patterns[37]: 0xBF00BFBFB0B0B0B0
-- patterns[38]: 0xFF7FBE5DA2418000
-- patterns[39]: 0xFAF5FAF5A050A050
-- checksum: 0x0
----- HyperTalk script -----
on domenu menu --// Added by Medior, Inc. 2/20/90
global RPStackName
if menu is in "Home,Quit HyperCard" and RPStackName is not empty then
set cursor to watch
put RPStackName into shortname
repeat until offset(":",shortname) = 0
delete char 1 to offset(":",shortname) of shortname
end repeat
delete last char of shortname
answer "This will return to "&shortname&"." with "Cancel" or "OK"
if it is "Cancel" then exit domenu
set cursor to watch
lock screen
go RPStackName
unlock screen with dissolve
exit domenu
else pass doMenu
end domenu
-- Copyright © 1988 Cincinnati Country Day School. All rights reserved.
-- This is the recursive algorithm that moves a tower of "height" disks
-- from the "source" pole to the "dest" pole using the "aux" pole as
-- the auxiliary. It works as follows: if height is 0, there is no
-- tower to move, and if source = dest, there is no movement, so in
-- this case the algorithm exits having done nothing. Otherwise, the
-- algorithm recursively calls itself to move a tower of height - 1
-- disks from the source to the auxiliary via the destination. Having
-- thus moved all overlying disks out of the way, the algorithm then
-- simply moves disk number "Height" from the source to the destination.
-- Finally, it again calls itself recursively to move the tower of
-- height - 1 disks from the auxiliary to the destination on top of disk
-- number "Height." See the script of the background for the details
-- of other handlers.
on moveTower height, source, dest, aux
add 1 to field depth
if height > 0 and source ≠ dest then
moveTower height - 1, source, aux, dest
moveDisk height, source, dest
moveTower height - 1, aux, dest, source
end if
subtract 1 from field depth
end moveTower
on moveDisk n, source, dest
global yBase, dHeight, stackHeight, xPole, poleTop
get "Disk" && n
put the loc of bkgnd button it into dSource
put "0,0" into dDest1
put item source of xPole into item 1 of dDest1
put poleTop into item 2 of dDest1
put dDest1 into dDest2
put item dest of xPole into item 1 of dDest2
put dDest2 into dDest3
put yBase - dHeight * item dest of stackHeight into item 2 of dDest3
drag from dSource to dDest1
drag from dDest1 to dDest2
drag from dDest2 to dDest3
subtract 1 from item source of stackHeight
add 1 to item dest of stackHeight
add 1 to field moves
end moveDisk